import 'package:flutter/material.dart';

class ShadowCard extends StatelessWidget {
  const ShadowCard({
    Key? key,
    required this.child,
    this.color = Colors.white,
    // this.shadowColor: const Color(0x80DCE7FA),
    this.shadowColor = Colors.transparent,
    this.margin =
        const EdgeInsets.only(left: 15.0, top: 15.0, right: 15.0, bottom: 0.0),
    this.radius = 8.0,
    // this.shadowOffset = const Offset(0.0, 2.0),
    this.shadowOffset = const Offset(0.0, 0.0),
    this.borderRadius,
  }) : super(key: key);

  final Widget child;
  final Color color;
  final Color shadowColor;
  final EdgeInsets margin;
  final double radius;
  final BorderRadiusGeometry? borderRadius;
  final Offset shadowOffset;

  @override
  Widget build(BuildContext context) {
    // return PhysicalModel(
    //   child: Column(
    //     children: _gridNavItems(context),
    //   ),
    //   color: Colors.transparent,//透明
    //   borderRadius: BorderRadius.circular(6),
    //   clipBehavior: Clip.antiAlias,//裁切
    // );

    return Container(
      margin: margin,
      child: DecoratedBox(
        decoration: BoxDecoration(
          color: color,
          // border: Border.all(color: Colors.orange, width: 5),
          // borderRadius: BorderRadius.circular(radius),
          borderRadius: borderRadius == null
              ? BorderRadius.circular(radius)
              : borderRadius,
          boxShadow: [
            BoxShadow(
              color: shadowColor,
              offset: shadowOffset,
              blurRadius: radius,
              spreadRadius: 0.0,
            ),
          ],
        ),
        child: ClipRRect(
          child: child,
          borderRadius: borderRadius ?? BorderRadius.circular(radius),
        ),
      ),
    );
  }
}
